package com.flying.common.service;

import org.apache.log4j.Logger;

import com.flying.common.util.ServiceHelper;
import com.flying.framework.annotation.Param;
import com.flying.framework.data.Data;
import com.flying.framework.service.AbstractService;

public class SequenceService extends AbstractService {
	private final static Logger log = Logger.getLogger(SequenceService.class);
	
	private String getProvider() {
		return this.serviceConfig.getConfig("provider");
	}
	
	public Data nextValue(@Param(value = "category", required=true) String category) {
		return ServiceHelper.invoke(this.getProvider(), "SequenceService:nextValue", new Data("category",category));
	}

	public Long nextLong(@Param(value = "category", required=true) String category) {
		Long result = this.nextValue(category).getLong("value");
		log.info("Sequence."+category+"="+result);
		return result;
	}
}
